package web

import (
	"net/http"
	"project/apis/services"
	"project/serializer"

	"github.com/gin-gonic/gin"
)

func Ping(c *gin.Context) {
	c.JSON(http.StatusOK, serializer.OutJson{
		Code: 200,
		Msg:  "Pong",
	})
}

func Test(c *gin.Context) {
	var user services.TestParam
	if err := c.ShouldBind(user); err == nil {
		userErr := user.TestService()
		if userErr == nil {
			c.JSON(http.StatusOK, serializer.OutJson{
				Code:  0,
				Msg:   "测试",
				Data:  nil,
				Error: "",
			})
			return
		}
		c.JSON(http.StatusOK, serializer.OutJson{
			Code:  0,
			Msg:   "测试",
			Data:  nil,
			Error: "",
		})
	} else {
		c.JSON(http.StatusOK, serializer.OutJson{
			Code:  0,
			Msg:   "测试",
			Data:  nil,
			Error: "",
		})
		return
	}

}
